home *** CD-ROM | disk | FTP | other *** search
- This file contains last minute changes to The C Window Library.
-
-
-
- MakeSound()
- -----------
-
- The MakeSound() function sounds a tone for a duration of time. Here is the
- prototype:
-
- void MakeSound(unsigned freq, unsigned millisec)
-
- where freq, is the frequency of the tone (in Hertz) and millisec is the
- number of milliseconds to sound the tone.
-
-
- Example:
- --------
-
- #include <window.h>
-
- main()
- {
- WindowInitializeSystem();
- /* Produce a 440 Hertz tone for 3 seconds */
- MakeSound(440,3000);
- }
-
- There is no error return for this function.
-
-
-
-
-
-
-
-
-
- The window_error_func function pointer
- --------------------------------------
-
- The window_error_func function pointer can point to an error function that
- is performed whenever there is an error encountered in one of The C Window
- Library functions. If the global variable check_existence_flag is set to 1
- and there is an error, The C Window Library will automatically call
- window_error_func. Here is the prototype:
-
- void (*window_error_func)(int errcode, char *sourcefile, int sourceline,
- char *funcname)
-
- The errcode is one of the defined error codes included in The C Window
- Library. Refer to page 6 of the main documentation for more information of
- the error codes and their definitions. The second argument is the name of
- the file where the error occurred. Only users with the source code to The
- C Window Library will have access to this file. The third argument is the
- offending line in the source file of where the error occurred. The last
- argument is the name of the function of where the error occurred.
-
- By default window_error_func points to a void null function (VOIDNULLFN),
- therefore no error function is called.
-
- Here is an example of how to implement automatic error checking:
-
-
- #include <window.h>
- #define WHITEONRED CREATE_VIDEO_ATTRIBUTE(red,white)
- void custom_error_func(int, char *, int, char *);
-
- WPOINTER w, error_window;
- void initialize_error();
-
- main()
- {
- WindowInitializeSystem();
- WindowSaveInitial(0);
- window_error_func = custom_error_func; /* Assign error function */
- initialize_error();
- WindowOpen(w); /* will be flagged for an error */
- }
-
- void initialize_error() /* Initialize error window and error handler */
- {
- error_window =
- WindowInitialize(BORDER,1,1,60,5,WHITEONRED,WHITEONRED,SINGLEBOX);
- WindowOpen(error_window);
- }
-
-
- void custom_error_func(int errcode, char *sourcefile, int sourceline,
- char *funcname)
- {
- int ch;
- MakeSound(100,500); /* Produce an error beep */
- if (errcode == NO_HEAP_MEM) /* Always check for the heap memory error
- separately */
- {
- VideoWriteString("You have ran out of Heap Memory",1,1);
- VideoWriteString(
- "Press 'Q' to quit program, Any other key to Continue...",2,1);
- }
-
- else /* Display error window */
- {
- WindowClear(error_window);
- WindowDisplay(error_window,1,EXPLODE);
- WindowPrintf(error_window,
- "Error Code: %d\nSource File: %s\nSource Line %d\nError Occurred in %s",
- errcode,sourcefile,sourceline,funcname);
- WindowWriteString(error_window,
- "Press 'Q' to quit program, Any other key to Continue...",5,1);
- }
-
- ch = GET_KEY();
- if (ch == 'Q' || ch == 'q')
- exit(0);
- else
- if (errcode != NO_HEAP_MEM)
- WindowHide(error_window,CONTRACT);
- }
-
-
- The above example initializes an error window and sets the window_error_func
- function pointer to point to the function custom_error_func(). Whenever an
- error occurs in The C Window Library, custom_error_func() will be called.
-
- Please note the check to see if the NO_HEAP_MEM error has occurred. It is
- important that you check for this error condition separately. The reason for
- this is that if there is not enough heap memory, you may inadvertently call a
- function in your error handler that calls on malloc() or any of the other
- memory allocation related functions. This will either freeze your system,
- or more peculiarly, cause your error handler to be called in an infinite
- loop because of the repeated failing calls to malloc() or its related
- functions. In the latter case, you will run out of stack space.
-
- If you want to unassign the window_error_code function pointer, use the
- following line in your code:
-
- window_error_func = VOIDNULLFN;
-
-
-
-
-
-
-
-
-
- Include files
- -------------
-
- KEYCODES.H is now automatically included when WINDOW.H is included.
-
-
-
-
-
-
-
-
-
- Input Options
- -------------
-
- There is a new option that can be used with the WindowGet..() family of
- functions:
-
- CHECKREGEXP_IGNORECASE - This option checks to see if the string entered
- matches the regular expression, but does a case insensitive check when a
- letter is encountered. For example "ABC", "abc", "Abc", etc. will be accepted
- if the regular expression is "3[A-Z]" and the CHECKREGEXP_IGNORECASE option
- is selected.
-
-
-
-
-
-
-
-
- Macros
- ------
-
- The following macros have now been added:
-
-
- GET_BGROUND_COLOR(c) - Returns the background color of the video attribute c.
-
- GET_FGROUND_COLOR(c) - Returns the foreground color of the video attribute c.
-
-
- VWINDOW_COORD_IN_VIEWPORT(w,row,col) - Returns 1 if the virtual window
- coordinates (row,col) are inside the
- viewport w, 0 otherwise. The virtual
- window must have w as a viewport.
-
-
- WINDOW_BORDER_COLOR(w) - Returns the border color of the window w.
-
-
- WINDOW_COLUMN(w) - Returns the absolute column of the upper left hand corner
- of the window.
-
- WINDOW_HEIGHT(w) - Returns the height of the text area of the window w.
-
-
- WINDOW_PAGENUM(w) - Returns the video page of where the window will be
- displayed.
-
- WINDOW_RANK(w) - Returns the rank of the window w.
-
-
- WINDOW_ROW(w) - Returns the absolute row coordinate of the upper left hand
- corner of the window w.
-
-
- WINDOW_TEXT_COLOR(w) - Returns the text color of the window w.
-
-
- WINDOW_WIDTH(w) - Returns the width of the text area of the window w.
-
-
-
-
-
-
-
-
-
-
-
-